package com.ask.mapper;

import com.ask.dto.SetMealQueryDTO;
import com.ask.entity.Dish;
import com.ask.entity.SetMeal;
import com.ask.vo.SetMealVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface SetMealMapper {
//    @Insert("insert into setmeal (category_id, name, price, description, image, create_time, update_time, create_user, update_user) VALUES " +
//            "(#{categoryId}, #{name}, #{price}, #{description}, #{image}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
    void insert(SetMeal setMeal);


    @Select("select * from setmeal where id = #{id}")
    SetMeal getById(Long id);

    Page<SetMealVO> pageQuery(SetMealQueryDTO setMealQueryDTO);

    void update(SetMeal setMeal);

    @Select("select d.* from dish d left join setmeal_dish s on d.id = s.dish_id where s.setmeal_id = #{setmealId}")
    List<Dish> getBySetMealId(Long setmealId);

    SetMealVO getByIdWithDish(Long id);

    void deleteBatch(List<Long> ids);

    @Delete("delete from setmeal where id = #{id}")
    void deleteById(Long id);

    List<SetMeal> list(SetMeal setMeal);

    Integer countByMap(Map map);
}
